package controllers

import (
	"github.com/kataras/iris/mvc"
	"github.com/kataras/iris"
	"smallstory/models"
)

type LoginController struct {
	mvc.C
}

func (c *LoginController) Login(ctx iris.Context) {

	uid := ctx.FormValue("uid")
	name := ctx.FormValue("name")
	headImg := ctx.FormValue("img")

	userDao := models.UserDao{}
	user := models.User{Uid: uid, Name: name, HeaderImg: headImg}

	if userDao.Save(&user) {
		ctx.JSON(ApiResponse{Code: 200, ErrorMessage: "登录成功", Data: &user})
	} else {
		ctx.JSON(ApiResponse{Code: 200, ErrorMessage: "登录失败", Data: &user})
	}

}
